//
//  NSString+Thumbnail.m
//  us
//
//  Created by karry on 2025/6/8.
//

#import "NSString+Thumbnail.h"

@implementation NSString (Thumbnail)

/// 获取图片缩略图
- (NSString *)photoThumbnail {
    return [self stringByAppendingString:@"?imageMogr2/thumbnail/!80p"];
}

/// 获取视频的封面图
- (NSString *)videoThumbnail {
    return [self stringByAppendingString:@"?ci-process=snapshot&time=0"];
}

- (CGFloat)fileSize {
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if ([fileManager fileExistsAtPath:self]) {
        NSDictionary *attrs = [fileManager attributesOfItemAtPath:self error:nil];
        unsigned long long size = [attrs fileSize];
        return size / (1024.0 * 1024.0); // 转换为 MB
    }
    return 0;
}
@end
